package jmine.tec.hydra.script.impl;

import jmine.tec.hydra.api.HydraMessage;
import jmine.tec.hydra.script.DecodeResult;
import jmine.tec.hydra.script.DecodeScriptContext;
import jmine.tec.script.persistent.context.impl.AbstractScriptExecutionContext;

/**
 * Contexto de execução de um script de decoding.
 * 
 * @author lundberg
 */
public class DecodeScriptContextImpl extends AbstractScriptExecutionContext<DecodeResult> implements DecodeScriptContext {

    private static final String MESSAGE = "_message";

    private static final String RESULT = "_result";

    private DecodeResult result;

    /**
     * Construtor
     */
    public DecodeScriptContextImpl() {
        // OK
    }

    /**
     * {@inheritDoc}
     */
    public DecodeScriptContext prepare(HydraMessage message) {
        this.getParameters().putParameter(MESSAGE, message, HydraMessage.class);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void beforeExecution() {
        this.result = new DecodeResult();
        this.getParameters().putParameter(RESULT, this.result);
    }

    /**
     * {@inheritDoc}
     */
    public DecodeResult getResult() {
        return this.result;
    }

    /**
     * {@inheritDoc}
     */
    public String getTracer() {
        return null;
    }
}
